/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package example_of_use;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import java.awt.BorderLayout;
import java.io.FileReader;
import javax.swing.JFrame;
import main.LogicImageSegmentation;
import weka.core.Instances;
import weka.gui.AttributeVisualizationPanel;

/**
*
* @author Reinhard
*/
public class PlotTesting {
    
    public PlotTesting(String filename,int numb_attribute){
        final JFrame jf = new JFrame("Attribute Visualization no " + numb_attribute);
        AttributeVisualizationPanel ap = new AttributeVisualizationPanel();
        try {
            Instances ins = new Instances(new FileReader(filename));
            ap.setInstances(ins);
            ap.setAttribute(numb_attribute);
        } catch (Exception ex) {
            System.out.println("NOVANTAT");
//            ex.printStackTrace();
//            System.exit(-1);
        }
        System.out.println("The attributes are: ");

        jf.setSize(500, 300);
        jf.getContentPane().setLayout(new BorderLayout());
        jf.getContentPane().add(ap, BorderLayout.CENTER);
        jf.setDefaultCloseOperation(jf.DISPOSE_ON_CLOSE);
        jf.setVisible(true);
    }

public static void main(String[] args) {
    // try {
    // Reader r = new BufferedReader(new FileReader("D:\\Kuliah\\Semester 6\\IF3054 - Intelegensia Buatan\\WEKA\\willwait.arff"));
    // Instances inst = new Instances(r);
    // final javax.swing.JFrame jf = new javax.swing.JFrame();
    // jf.getContentPane().setLayout(new java.awt.BorderLayout());
    // AttributeSummarizer as = new AttributeSummarizer();
    // as.setInstances(inst);
    // System.out.println(as.getColoringIndex());
    //
    // jf.getContentPane().add(as, java.awt.BorderLayout.CENTER);
    // jf.addWindowListener(new java.awt.event.WindowAdapter() {
    //
    // public void windowClosing(java.awt.event.WindowEvent e) {
    // jf.dispose();
    // System.exit(0);
    // }
    // });
    // jf.setSize(830, 600);
    // jf.setVisible(true);
    // } catch (Exception ex) {
    // ex.printStackTrace();
    // System.err.println(ex.getMessage());
    // }
//        if (args.length != 3) {
//        final JFrame jf = new JFrame("AttribVisualization");
//        AttributeVisualizationPanel ap = new AttributeVisualizationPanel();
//        try {
//            Instances ins = new Instances(new FileReader("src/java/data_set/image_segmentation_data.arff"));
//            ap.setInstances(ins);
//            ap.setAttribute(ins.numAttributes() - 2);
//        } catch (Exception ex) {
//            ex.printStackTrace();
//            System.exit(-1);
//        }
//            System.out.println("The attributes are: ");
//
//            jf.setSize(500, 300);
//            jf.getContentPane().setLayout(new BorderLayout());
//            jf.getContentPane().add(ap, BorderLayout.CENTER);
//            jf.setDefaultCloseOperation(jf.EXIT_ON_CLOSE);
//            jf.setVisible(true);
//        } else {
//            System.out.println("Usage: java AttributeVisualizationPanel"+ " [arff file] [index of attribute]");
//        }
        PlotTesting pt = new PlotTesting(LogicImageSegmentation.FILE_DATA_SET_NAME_ARFF, 1);
    }

}